#!/usr/bin/python
#-*-<coding=UTF-8>-*-

"""
This programe shows the grid sizer usage.
grid sizer最大的特点是放置在sizer中的控件从左到右，从上到下的依次排列.直到最后一个窗口.
需要注意的是sizer的Add()方法的参数,会控制显示的间隙是否要填充等; 具体参数的含义请从注释说明.
"""

import wx
from wx_blockWindow import BlockWindow

labels = "one two three four five six seven eight nine".split()
flags = {"one":wx.ALIGN_BOTTOM,"two":wx.ALIGN_CENTER,
        "four":wx.ALIGN_RIGHT,"six":wx.EXPAND,"seven":wx.EXPAND,
        "eight":wx.SHAPED}

class GridSizerFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,-1,"Basic Grid Sizer")
        sizer = wx.GridSizer(rows=3,cols=3,hgap=5,vgap=5)
        for label in labels:
            bw = BlockWindow(self,label=label)
            flag = flags.get(label,0)
            sizer.Add(bw,0,flag)
        center = self.FindWindowByName("five")
        center.SetMinSize((150,150))
        self.SetSizer(sizer)
        self.Fit()

if __name__ == "__main__":
    app = wx.PySimpleApp()
    GridSizerFrame().Show()
    app.MainLoop()
